package my.ssma.controller.impl;

import my.ssma.controller.UserMapperController;
import my.ssma.domain.User;
import my.ssma.service.UserBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping(value = "/userMapper", produces = "application/json; charset=utf-8")
public class UserMapperControllerImpl implements UserMapperController {

    @Autowired
    private UserBaseService userBaseService;

    @GetMapping("/findAll")
    @Override
    public List<User> selectList() {
        return userBaseService.SelectList();
    }

    @GetMapping("findById/{id}")
    @Override
    public User findById(@PathVariable("id") Integer id) {
        return userBaseService.findById(id);
    }

    @GetMapping("findNameLike/{name}")
    @Override
    public List<User> nameLike(@PathVariable("name") String name) {
        return userBaseService.nameLike(name);
    }

    @GetMapping("gl/{id}")
    @Override
    public List<User> greatThen(@PathVariable("id") Integer id) {
        return userBaseService.greatThen(id);
    }

    @Override
    @GetMapping("/page/{pageNum}/{pageSize}")
    public List<User> pageable(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize){
        return userBaseService.pageable(pageNum, pageSize);
    }

    @Override
    @GetMapping("/page2/{pageNum}/{pageSize}")
    public List<User> pageable2(@PathVariable("pageNum") Integer pageNum, @PathVariable("pageSize") Integer pageSize) {
        return userBaseService.pageable2(pageNum, pageSize);
    }
}
